<!-- 首页 -->
<template>
	<view v-if="chat_flag == 1">
		<tn-custom bgColor="bg-gradual-pink" :isBack="false">
			<block slot="left">
				<view class="btn-left" @click="shaixuan">
					<u-icon name="shaixuan" custom-prefix="iconfont"></u-icon>
					<view class="left-text">筛选</view>
				</view>
			</block>
			<block slot="content">找人聊天</block>
		</tn-custom>
		
		<vip :scrollTop="scrollTop" ref="vip"></vip>
		<coin-popup></coin-popup>
		<user-auth></user-auth>
		<user-phone></user-phone>
		<user-pay></user-pay>
		<search-popup ref="search" @query="query"></search-popup>
	</view>
</template>

<script>
import {mapState} from 'vuex';
import base from '@/config/baseUrl.js';
import vip from "./vip.vue"; // 关注
export default {
	components: {
		vip,
	},
	data() {
		return {
			systemInfo: base.systemInfo,
			scrollTop: 0,
		};
	},
	created() {
		this.init();
	},
	onShow() {
		this.$u.get('/system/config/getChatValue',{
			appId: this.website.appId,
			userId: this.vuex_user.userId,
		}).then(res => {
			this.$store.commit('setChatFlag', res.data);
			this.vuex_tabbarList[0].show = res.data;
			this.vuex_tabbarList[2].show = res.data;
			this.vuex_tabbarList[3].show = res.data;
			this.vuex_tabbarList[4].show = res.data;
			this.$store.commit('setTabbar', this.vuex_tabbarList);
		});
		
		this.$u.get('/system/user/getMyInfo').then(res => {
			this.user = res.user;
			this.$store.commit('setUser', this.user);
			this.$store.commit('setNoticeNum', this.user.giveNewNum+this.user.commentNewNum);
			if(this.user.isWelcome == 0){
				uni.reLaunch({
				  url: '/packgeMine/pages/me/welcome/welcome'
				});
			}
		});
	},
	onShareAppMessage(res) {
		return {
			title: '送你一个对象，快来「处CP」吧！',
			path: '/pages/index/world/index',
			imageUrl: 'http://rbtnet.oss-cn-hangzhou.aliyuncs.com/test/20220914/58242695c2a8421b892eced5f1bd3b15.jpeg',
		};
	},
	onShareTimeline() {
		return {
			title: '送你一个对象，快来「处CP」吧！',
			path: '/pages/index/world/index',
			imageUrl: 'http://rbtnet.oss-cn-hangzhou.aliyuncs.com/test/20220914/58242695c2a8421b892eced5f1bd3b15.jpeg',
		};
	},
	onPageScroll(e) {
		this.scrollTop = e.scrollTop;
	},
	onReachBottom() {
		this.$refs.vip.load();
	},
	onPullDownRefresh(){
		//刷新后的效果
		this.$refs.vip.query();
		uni.stopPullDownRefresh();  //刷新数据之后停止刷新效果
	},
	computed: {
		...mapState(['vuex_user','chat_flag','vuex_tabbarList']),
	},
	methods: {
		init() {
			// 需要固定swiper的高度
			// #ifndef MP-ALIPAY
			this.height = (uni.getSystemInfoSync().screenHeight - this.systemInfo.navBarH - this.systemInfo.tabbarH - 40) + 'px'
			// #endif
		},
		shaixuan() {
			this.$refs.search.open();
		},
		query() {
			this.$refs.vip.query();
		},
	}
};
</script>
<style lang="scss" scoped>
	page {
		background-color: #fff;
	}
	.top-box {
		display: flex;
		background-color: #fff;
		align-items: center;
		height: 40px;
		justify-content: space-between;
	}
	.u-tabs-list {
		display: flex;
		align-items: center;
		flex: 1;
	}
	.u-tabs-box {
		display: flex;
		flex: 1;
		align-items: center;
		justify-content: center;
	}
	.u-tabs {
		padding: 5px 0;
		font-size: 28rpx;
		display: flex;
	}
	.u-tabs-active {
		font-weight: bolder;
		color: #a569d9;
		border-bottom: 2px solid #a569d9;
	}
	.amount {
		font-size: 26rpx;
		margin-right: 15px;
		font-weight: bolder;
		line-height: 80rpx;
		color: #2979ff;
	}
	.user-box {
		display: flex;
		align-items: center;
		padding: 15px;
		padding-bottom: 0;
	}
	.user-name-box {
		display: flex;
		align-items: center;
	}
	.nickname {
		font-size: 28rpx;
		margin-right: 5px;
	}
	.sex-box {
		background-color: #2b85e4;
		display: flex;
		color: #fff;
		padding: 4rpx 10rpx;
		border-radius: 20px;
		font-size: 16rpx;
	}
	.sex-box-nv {
		background-color: #fe709f;
		display: flex;
		color: #fff;
		padding: 4rpx 10rpx;
		border-radius: 20px;
		font-size: 16rpx;
	}
	.user-tag-box {
		display: flex;
		align-items: center;
	}
	.user-tag {
		font-size: 20rpx;
		color: #82848a;
		margin: 10rpx 0;
	}
	.user-box-right {
		margin-left: 15px;
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex: 1;
	}
	.sign-name {
		font-size: 24rpx;
		color: #8d8d8d;
		text-overflow: ellipsis;
		width: 400rpx;
		overflow: hidden;
		white-space: nowrap;
	}
	.line {
		float:left;
		width: 1px;
		height: 16rpx; 
		background: #e5e5e5;
		margin: 0 5px;
	}
	.loadmore-box {
		padding: 15px;
	}
	.btn-left {
		font-size: 28rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border: 1px solid #e6028e;
		margin-left: 20px;
		padding: 8rpx 20rpx;
		border-radius: 20px;
	}
	.left-text {
		margin-left: 10rpx;
		font-size: 28rpx;
	}
</style>
